

// import JSEncrypt from 'jsencrypt'
import { JSEncrypt } from 'encryptlong'


//公钥
var PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC6ue+kZ26M7T/FTsXjmnokTETe
yEyvtj4u42K30cJ9IIUTq+mXx2IVeysafZJXp/6APfIQbVh4YWfA2Bat4RMxEfsO
x1mDKCNYTMF5Eotrcur27XiQfnAjs8Yu9+OcxuAOdBq6LRAd1QHpj/gLXUARGF5G
b+qPc0fULFe0eFEdfwIDAQAB
-----END PUBLIC KEY-----`;
//私钥
var PRIVATE_KEY = ``;

/**
 * @summary 加密
 */
export const encryptMI = (origin) => {
  const encrypt = new JSEncrypt()
  encrypt.setPublicKey(PUBLIC_KEY)
  return encrypt.encryptLong(origin)
}

/**
 * @summary 解密
 */
export const decryptMI = (cipher) => {
  const decrypt = new JSEncrypt()
  decrypt.setPrivateKey(PRIVATE_KEY)
  return decrypt.decryptLong(cipher)
}

// let a = {page:10,list:[
// 	{d_a:555},
// 	{d_a:555},
// 	{d_a:555}
// ]}
// let b = encryptMI(JSON.stringify(a)) //加密
// let c = decryptMI('pLTcr9Cw8dNthYo1UU5tyV8NaltkXcZOqi0_BxRJ_wLBVrMw9iIyRzKeLPzMOKZIo-hqHtZUAFVp5fpoDnNui-_s3jpTMf9KQ-O1an0sODO7d01Xls0igMWKqNaEwD_zdFi4ii-UXBDa0jOd1Y-reoznH6VWIs0pxTHdpMCS33o') //解密
// console.log('加密：',b);
// console.log('解密：',JSON.parse(c));